import { getIpAPI } from '@/api/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'User',
  () => {
    /** 用户标识 */
    const user = ref<string | number>('')
    /** 获取用户标识 */
    const getUser = async () => {
      if (user.value) return
      const res = await getIpAPI()
      user.value = res.data
    }

    return { user, getUser }
  },
  {
    persist: true
  }
)
